﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ECS.Framework
{
    public static class Export
    {
        /// <summary>
        /// write text file for MAWB information
        /// </summary>
        /// <param name="destinationPath">destination folder</param>
        /// <param name="flightDate">flight date</param>
        /// <param name="flightNo">flight number</param>
        /// <param name="destination">flight destination</param>
        /// <param name="mawbPrefix">Prefix MAWB</param>
        /// <param name="mawbSN">Serial MAWB</param>
        /// <param name="pieces">pieces count</param>
        /// <param name="NoG">Nature of goods</param>
        public static void WriteMawbFile(string destinationPath, string flightDate,string fblFlightNO, string flightNo, string destination, string mawbPrefix, string mawbSN, string pieces, string NoG)
        {
            string a = flightDate.Substring(0, 5);
            if (!Directory.Exists(destinationPath))
            {
                Directory.CreateDirectory(destinationPath);
            }
            String filename = "FBL_" + flightNo + "_" + a + ".txt";
            string path = Path.Combine(destinationPath, filename);
            StreamWriter writeStream = new StreamWriter(path);
            writeStream.WriteLine("FBL/3");
            writeStream.Write("1/");
            writeStream.Write(fblFlightNO);
            writeStream.Write("/");
            writeStream.Write(a);
            writeStream.Write("/");
            writeStream.WriteLine("BKK");
            writeStream.WriteLine(destination);
            writeStream.Write(mawbPrefix);
            writeStream.Write("-");
            writeStream.Write(mawbSN);
            writeStream.Write("BKK");
            writeStream.Write(destination);
            writeStream.Write("/");
            writeStream.Write("P");
            writeStream.Write(pieces);
            writeStream.Write("K");
            writeStream.Write(0);
            writeStream.Write("T");
            writeStream.Write(0);
            writeStream.Write("/");
            writeStream.WriteLine(NoG);
            writeStream.Write("LAST");
            writeStream.Close();
            writeStream.Dispose();
        }
    }
}
